package cn.com.yang.egg;

/**
 * @Desc<静态分派和重载>
 * @Author 杨亿金
 * @Date 2021/1/14 8:50
 * @CopyRight
 * @Version
 */
public class StaticDispatch {
    static abstract class Human{}
    static class Man extends Human{}
    static class Woman extends Human{}
    public void sayHello(Human human){
        System.out.println("hello guy!");
    }
    public void sayHello(Man man){
        System.out.println("hello man!");
    }
    public void sayHello(Woman woman){
        System.out.println("hello lady!");
    }

    /**
     * 静态类型与实际类型
     * @param args
     */
    public static void main(String[] args) {
        Human man = new Man();
        Human woman = new Woman();
        StaticDispatch dispatch = new StaticDispatch();
        dispatch.sayHello(man);
        dispatch.sayHello(woman);
    }
    /**
     * 所有依赖静态类型来决定方法执行版本的分派动作，都成为静态分派。静态分派最典型的应用表现就是方法重载。
     *
     */
}
